package com.gitee.magic.framework.head.vo;

import java.io.Serializable;
import java.util.Date;

import com.gitee.magic.core.converter.PropertyConverter;
import com.gitee.magic.framework.head.converter.TimeStampConverterEditor;

import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;

/**
 * @author start
 */
public class BaseVO implements Serializable {
	
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Schema(description = "是否成功 状态码(200-299)都为成功",requiredMode = RequiredMode.REQUIRED)
	private Boolean success;
	
	@Schema(description = "状态码，程序执行中的一种状态'200:表示执行完毕,204:未获取到数据等[详情](/static/doc/response_code.html)",example = "200",requiredMode = RequiredMode.REQUIRED)
	private Integer code;

	@Schema(description = "状态消息（仅供开发对接,展示请根据Code单独处理）",example = "OK",requiredMode = RequiredMode.REQUIRED)
	private String message;

	@Schema(description = "日志编号本次请求的唯一标识,当无法解决问题时可把它发给工程师")
	private String logno;

	@Schema(description = "应用名称",requiredMode = RequiredMode.REQUIRED)
	private String name;

	@Schema(description = "服务器时间",requiredMode = RequiredMode.REQUIRED)
	@PropertyConverter(TimeStampConverterEditor.class)
	private Date servertime;
	
	public BaseVO() {}

	public BaseVO(Integer code,String message, String logno,String name) {
		this.name=name;
		this.code = code;
		this.message = message;
		this.logno = logno;
		this.success=this.code>=200&&this.code<=299;
		this.servertime = new Date();
	}
	
	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLogno() {
		return logno;
	}

	public void setLogno(String logno) {
		this.logno = logno;
	}

	public Date getServertime() {
		return servertime;
	}

	public void setServertime(Date servertime) {
		this.servertime = servertime;
	}

	@Override
	public String toString() {
		return "BaseVO{" +
				"code=" + code +
				", message='" + message + '\'' +
				", logno='" + logno + '\'' +
				", name='" + name + '\'' +
				", servertime=" + servertime +
				'}';
	}
}

